<template>
    <div>
          <h1>登录</h1>
          <p>用户名:<a-input placeholder="用户名" v-model="username" style="width:300px"/></p>
          <p>密码:<a-input placeholder="密码" v-model="password" type='password' style="width:300px"/></p>
          <p><a-button type="primary"  style="width:80px" @click="denglu">登录</a-button></p>


    </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
          username:'',
          password:'123'
        }
    },
    methods: {
         denglu(){
             this.$axios({
                 'url':'long/',
                 'method':'POST',
                 'data':{
                     'username':this.username,
                     'password':this.password
                 }
             }).then(resp=>{
                 if(resp.data.code==200){
                     localStorage.setItem('token',resp.data.token)
                     localStorage.setItem('username',this.username)
                     this.$router.push('/')
                 }
                 console.log(resp.data)
                 alert(resp.data.msg)
             }).catch(error=>{
                 console.log(resp.data)
                 alert(resp.data.msg)
             })
         }
    },
    created() {

    }
}
</script>

<style scoped>

</style>
